<!--
  ~ Licensed to the Apache Software Foundation (ASF) under one
  ~ or more contributor license agreements.  See the NOTICE file
  ~ distributed with this work for additional information
  ~ regarding copyright ownership.  The ASF licenses this file
  ~ to you under the Apache License, Version 2.0 (the
  ~ "License"); you may not use this file except in compliance
  ~ with the License.  You may obtain a copy of the License at
  ~
  ~     http://www.apache.org/licenses/LICENSE-2.0
  ~
  ~ Unless required by applicable law or agreed to in writing, software
  ~ distributed under the License is distributed on an "AS IS" BASIS,
  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  ~ See the License for the specific language governing permissions and
  ~ limitations under the License.
  -->

<ng-container *ngIf="node">
  <div class="name">
    {{ node.detail.name }}
  </div>
  <div nz-row class="wrapper">
    <div nz-col [nzSpan]="12">
      <form nz-form class="small">
        <nz-form-item>
          <nz-form-label [nzSpan]="9">Status</nz-form-label>
          <nz-form-control [nzSpan]="15">
            <nz-form-text>
              <flink-job-badge [state]="node.detail.status"></flink-job-badge>
            </nz-form-text>
          </nz-form-control>
        </nz-form-item>
        <nz-form-item>
          <nz-form-label [nzSpan]="9">Parallelism</nz-form-label>
          <nz-form-control [nzSpan]="15">
            <nz-form-text>{{ node.detail.parallelism }}</nz-form-text>
          </nz-form-control>
        </nz-form-item>
        <nz-form-item>
          <nz-form-label [nzSpan]="9">Start Time</nz-form-label>
          <nz-form-control [nzSpan]="15">
            <nz-form-text>{{ node.detail['start-time'] | humanizeDate: 'yyyy-MM-dd HH:mm:ss' }}</nz-form-text>
          </nz-form-control>
        </nz-form-item>
        <nz-form-item>
          <nz-form-label [nzSpan]="9">End Time</nz-form-label>
          <nz-form-control [nzSpan]="15">
            <nz-form-text>{{ node.detail['end-time'] | humanizeDate: 'yyyy-MM-dd HH:mm:ss' }}</nz-form-text>
          </nz-form-control>
        </nz-form-item>
        <nz-form-item>
          <nz-form-label [nzSpan]="9">Duration</nz-form-label>
          <nz-form-control [nzSpan]="15">
            <nz-form-text>{{ node.detail.duration | humanizeDuration }}</nz-form-text>
          </nz-form-control>
        </nz-form-item>
      </form>
    </div>
    <div nz-col [nzSpan]="12">
      <form nz-form class="small">
        <nz-form-item>
          <nz-form-label [nzSpan]="9">Task</nz-form-label>
          <nz-form-control [nzSpan]="15">
            <nz-form-text>
              <flink-task-badge [tasks]="node.detail.tasks"></flink-task-badge>
            </nz-form-text>
          </nz-form-control>
        </nz-form-item>
        <nz-form-item>
          <nz-form-label [nzSpan]="9">Records Sent</nz-form-label>
          <nz-form-control [nzSpan]="15">
            <nz-form-text>
            <span *ngIf="node.detail.metrics['write-records-complete'];else loadingTemplate">
              {{ node.detail.metrics['write-records'] | number:'1.0-0' }}
            </span>
            </nz-form-text>
          </nz-form-control>
        </nz-form-item>
        <nz-form-item>
          <nz-form-label [nzSpan]="9">Bytes Received</nz-form-label>
          <nz-form-control [nzSpan]="15">
            <nz-form-text>
            <span *ngIf="node.detail.metrics['read-bytes-complete'];else loadingTemplate">
              {{ node.detail.metrics['read-bytes'] | humanizeBytes }}
            </span>
            </nz-form-text>
          </nz-form-control>
        </nz-form-item>
        <nz-form-item>
          <nz-form-label [nzSpan]="9">Records Received</nz-form-label>
          <nz-form-control [nzSpan]="15">
            <nz-form-text>
            <span *ngIf="node.detail.metrics['read-records-complete'];else loadingTemplate">
              {{ node.detail.metrics['read-records'] | number:'1.0-0' }}
            </span>
            </nz-form-text>
          </nz-form-control>
        </nz-form-item>
        <nz-form-item>
          <nz-form-label [nzSpan]="9">Bytes Sent</nz-form-label>
          <nz-form-control [nzSpan]="15">
            <nz-form-text>
            <span *ngIf="node.detail.metrics['write-bytes-complete'];else loadingTemplate">
              {{ node.detail.metrics['write-bytes'] | humanizeBytes }}
            </span>
            </nz-form-text>
          </nz-form-control>
        </nz-form-item>
      </form>
    </div>
  </div>
  <ng-template #loadingTemplate>
    <i nz-icon type="loading"></i>
  </ng-template>
</ng-container>
